package com.fastCms.business.frame.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fastCms.business.frame.constant.CommonConst;
import com.fastCms.business.frame.daos.CloudRoleMapper;
import com.fastCms.business.frame.daos.CloudUserRoleRelMapper;
import com.fastCms.business.frame.pojo.entity.CloudRole;
import com.fastCms.business.frame.pojo.entity.CloudUserRoleRel;
import com.fastCms.business.frame.service.CloudRoleService;
import com.fastCms.business.frame.service.CloudUserRoleRelService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 平台角色表 服务实现类
 * </p>
 *
 * @author liusq
 * @since 2019-10-15
 */
@Service
public class CloudRoleServiceImpl extends ServiceImpl<CloudRoleMapper, CloudRole> implements CloudRoleService {
    @Override
    public CloudRole findByRoleId(String roleId) {
        QueryWrapper<CloudRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("id", roleId);
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        return this.getOne(queryWrapper);
    }

    @Override
    public CloudRole findByRoleName(String roleName, String organizeCode, String platform) {
        QueryWrapper<CloudRole> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("role_name", roleName);
        queryWrapper.eq("organize_code", organizeCode);
        queryWrapper.eq("platform", platform);
        queryWrapper.eq("state", CommonConst.STATE.VALID);
        return this.getOne(queryWrapper);
    }
}
